<?php

namespace app\model;
use app\util\Tools;
class Task extends Base
{
    protected $autoWriteTimestamp = true;
    protected $resultSetType = 'collection';
    protected $updateTime = 'updateTime';
    protected $createTime = 'addTime';

    public function getrewardMoneyAttr($value){
        return Tools::bcCalculate($value, 100, '/');
    }

    public function setrewardMoneyAttr($value){
        return $value * 100;
    }

    public function getStatusTextAttr($value, $data) {
        $status = ['-1' => '审核中','1' => '通过', '2' => '驳回', '3' => '取消'];
        return isset($status[$data['status']])?$status[$data['status']]:'未知';
    }

    public function getisUpTextAttr($value,$data) {
        $status = ['1' => '上架', '2' => '下架'];
        return isset($status[$data['isUp']])?$status[$data['isUp']]:'未知';
    }

    public function getisOpenTextAttr($value,$data) {
        $status = ['1' => '开放', '2' => '不开放'];
        return isset($status[$data['isOpen']])?$status[$data['isOpen']]:'未知';
    }

    public function gettimesTextAttr($value,$data) {
        $status = ['1' => '每天一次', '2' => '每周一次', '3' => '每月一次', '4' => '每年一次', 5 => '只能一次'];
        return isset($status[$data['times']])?$status[$data['times']]:'未知';
    }
}
